console.log("factory");
(() => {
  const oModal = document.getElementsByClassName("modal")[0];
  const oBtns = document.getElementsByClassName("btns")[0];
  const init = () => {
    bindEvent()
  };
  init()
  function bindEvent() {
    oBtns.addEventListener("click", handleBtnClick, false);
  }
  function handleBtnClick(e) {
    const tar = e.target;
    const tagName = tar.tagName.toLowerCase();
    if (tagName === "button") {
      const status = tar.dataset.status;
      changeStatus(status);
    }
  }

  function changeStatus(status) {
    switch (status) {
      case "success":
        oModal.className = "modal success";
        break;
      case "warning":
        oModal.className = "modal warning";
        break;
      case "danger":
        oModal.className = "modal danger";
        break;
      default:
        break;
    }
  }
})();
